<?php

function smarty_function_get_all_subcategory($params, &$smarty) {

    $pntables = pnDBGetTables();
    $tableCategory  = $pntables['innoforum_category'];
    $columncategory = $pntables['innoforum_category_column'];
    $tableSubCategory  = $pntables['innoforum_subcategory'];
    $columnSubCategory = $pntables['innoforum_subcategory_column'];

    $sql = "SELECT
              $tableCategory.$columncategory[id],  
              $tableCategory.$columncategory[name],  
              $tableSubCategory.$columnSubCategory[id],  
              $tableSubCategory.$columnSubCategory[name]  
            FROM
              $tableCategory,
              $tableSubCategory
            WHERE
              $tableCategory.$columncategory[id] = $tableSubCategory.$columnSubCategory[category_id]
            ORDER BY 
              $tableCategory.$columncategory[name] ASC ";

    $column = array("cat_id", "cat_name","subcat_id", "name");
    $result = DBUtil::executeSQL($sql);
    $subcategoryArray = DBUtil::marshallObjects ($result, $column);
 
    if ($subcategoryArray) {
        $smarty->assign('subcategoryArray', $subcategoryArray); 
    } else {
        return "";
    }
}